// JS Created at 6/25/2019 4:01:44 PM
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// site-specific declarations
// test
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
var m_blnDoBodyUnload = false;
var m_winAddressManager;
var m_BlinkTopAlertBarTID;
//the following "BarHeight" values MUST equal height + border-width as defined in global_base.css
var m_iTopAlertBarHeight = 21;
var m_iTopToolBarHeight = 25;
var ProgressID; // for polling progress bar
var ShowProgressBar = false;
var DefaultTimer;
var CategorySearchResults = [];
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// site-specific functions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function WriteAdminNavBar(LinkedMemberExists, HasMemberAuthID, MemberName, IsContentAdmin, SmartLink)
{
try { if (m_blnSuppressAdminNavBar) return; } catch (e) { };
var sContent = '';
if (HasMemberAuthID) {
sContent += '
YOU ARE SIGNED IN AS: ';
sContent += ('' + MemberName);
sContent += ' (SIGN OUT)
';
WriteTopAlertBar(sContent);
}
function ToggleAdminEditMode() {
var toggle = getCookie("AdminEditMode");
if (toggle != null) {
if (toggle == "1") {
setCookie("AdminEditMode", "0", "/", 1);
}
else {
setCookie("AdminEditMode", "1", "/", 1);
}
}
else {
setCookie("AdminEditMode", "0", "/", 1);
}
window.location.reload();
return;
}
function WriteTopAlertBar(sContent, iBlinks) {
var TopAlertBarText = document.getElementById('TopAlertBarText');
if (TopAlertBarText) { //update alert bar text
TopAlertBarText.innerHTML = sContent;
} else {
//create the alert bar
var TopAlertBar = document.createElement('div');
TopAlertBar.setAttribute('id', 'TopAlertBar');
TopAlertBarText = document.createElement('div');
TopAlertBarText.setAttribute('id', 'TopAlertBarText');
TopAlertBarText.onmouseover = function() {
document.getElementById('TopAlertBarText').style.display = '';
clearTimeout(m_BlinkTopAlertBarTID);
};
TopAlertBarText.innerHTML = sContent;
TopAlertBar.appendChild(TopAlertBarText);
var docBody = document.getElementsByTagName('body')[0];
docBody.appendChild(TopAlertBar);
}
if ((!isNaN(iBlinks)) && iBlinks > 0) BlinkTopAlertBar(iBlinks);
var $ToolBar = $("#TopAlertBar");
// Create sticky tool bar
StickyFooter($ToolBar);
// Hide Tool Bar on scroll
HideOnScroll($ToolBar);
}
function WriteTopToolBar(sContent) {
var TopToolBarText = document.getElementById('TopToolBarText');
if (TopToolBarText) { //update top toolbar text
TopToolBarText.innerHTML = sContent;
} else {
//create the toolbar
var iTop = 0;
if (document.getElementById('TopAlertBar')) {
iTop = (m_iTopAlertBarHeight * 1);
}
var TopToolBar = document.createElement('div');
TopToolBar.setAttribute('id', 'TopToolBar');
TopToolBarText = document.createElement('div');
TopToolBarText.setAttribute('id', 'TopToolBarText');
TopToolBarText.innerHTML = sContent;
TopToolBar.appendChild(TopToolBarText);
var docBody = document.getElementsByTagName('body')[0];
docBody.appendChild(TopToolBar);
var TopAlertBarHeight = 21;
var $ToolBar = $("#TopToolBar");
if (document.getElementById('TopAlertBar')) {
StickyFooterWithAlertBar($ToolBar);// account for the extra space of the admin bar
HideOnScroll($ToolBar);
}
else
{
StickyFooter($ToolBar);// no admin bar present
HideOnScroll($ToolBar);
}
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Progress bar functions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function CreateProgressBarMarkup() {
// create empty divs that will hold the information from the jquery ajax call in function WriteProgressBar
// var CurrentScoreHiddenField = document.createElement('input');
// CurrentScoreHiddenField.setAttribute('type', 'hidden');
// CurrentScoreHiddenField.setAttribute('id', 'CurrentScore');
// var GameLevelNameHiddenField = document.createElement('input');
// GameLevelNameHiddenField.setAttribute('type', 'hidden');
// GameLevelNameHiddenField.setAttribute('id', 'GameLevelName');
// var BarEnabledHiddenField = document.createElement('input');
// BarEnabledHiddenField.setAttribute('type', 'hidden');
// BarEnabledHiddenField.setAttribute('id', 'IsProgressBarEnabled');
// var GameLevelHiddenField = document.createElement('input');
// GameLevelHiddenField.setAttribute('type', 'hidden');
// GameLevelHiddenField.setAttribute('id', 'GameLevel');
// var ScoreUpdatedHiddenField = document.createElement('input');
// ScoreUpdatedHiddenField.setAttribute('type', 'hidden');
// ScoreUpdatedHiddenField.setAttribute('id', 'ScoreUpdated');
// var ShowProgressBarAlwaysHiddenField = document.createElement('input');
// ShowProgressBarAlwaysHiddenField.setAttribute('type', 'hidden');
// ShowProgressBarAlwaysHiddenField.setAttribute('id', 'ShowProgressBarAlways');
// var HasCurrentBadgeMarkupHiddenField = document.createElement('input');
// HasCurrentBadgeMarkupHiddenField.setAttribute('type', 'hidden');
// HasCurrentBadgeMarkupHiddenField.setAttribute('id', 'HasCurrentBadgeMarkup');
// var HasNextBadgeMarkupHiddenField = document.createElement('input');
// HasNextBadgeMarkupHiddenField.setAttribute('type', 'hidden');
// HasNextBadgeMarkupHiddenField.setAttribute('id', 'HasNextBadgeMarkup');
var CurrentScoreDiv = document.createElement('div');
CurrentScoreDiv.setAttribute('id', 'CurrentScore');
CurrentScoreDiv.style.display = 'none';
var GameLevelNameDiv = document.createElement('div');
GameLevelNameDiv.setAttribute('id', 'GameLevelName');
GameLevelNameDiv.style.display = 'none';
var BarEnabledDiv = document.createElement('div');
BarEnabledDiv.setAttribute('id', 'IsProgressBarEnabled');
BarEnabledDiv.style.display = 'none';
var GameLevelDiv = document.createElement('div');
GameLevelDiv.setAttribute('id', 'GameLevel');
GameLevelDiv.style.display = 'none';
var ScoreUpdatedDiv = document.createElement('div');
ScoreUpdatedDiv.setAttribute('id', 'ScoreUpdated');
ScoreUpdatedDiv.style.display = 'none';
// Create the tool bar that will hold the progress bar stuff
var progressToolBarDiv = document.createElement('div');
progressToolBarDiv.setAttribute('id', 'ProgressToolBar');
progressToolBarDiv.style.display = 'none';
var ShowProgressBarDiv = document.createElement('div');
ShowProgressBarDiv.setAttribute('id', 'ShowProgressBarAlways');
ShowProgressBarDiv.style.display = 'none';
var HasCurrentBadgeMarkupDiv = document.createElement('div');
HasCurrentBadgeMarkupDiv.setAttribute('id', 'HasCurrentBadgeMarkup');
HasCurrentBadgeMarkupDiv.style.display = 'none';
var HasNextBadgeMarkuDiv = document.createElement('div');
HasNextBadgeMarkuDiv.setAttribute('id', 'HasNextBadgeMarkup');
HasNextBadgeMarkuDiv.style.display = 'none';
var YuiDiv = document.createElement('div');
YuiDiv.setAttribute('class', 'yui-skin-sam');
// I'm lazy, create the inner tool bar with text that will be placed inside the progress tool bar
var progressToolBarInnerHtml = '
' +
'
' +
'';
var YuiDivInnerHtml = '
' +
'' +
'
';
YuiDiv.innerHTML = YuiDivInnerHtml;
// put those divs inside the progress tool bar
progressToolBarDiv.innerHTML = progressToolBarInnerHtml;
// append everything!
var docBody = document.getElementsByTagName('body')[0];
// docBody.appendChild(CurrentScoreHiddenField);
// docBody.appendChild(GameLevelNameHiddenField);
// docBody.appendChild(BarEnabledHiddenField);
// docBody.appendChild(GameLevelHiddenField);
// docBody.appendChild(ScoreUpdatedHiddenField);
// docBody.appendChild(ShowProgressBarAlwaysHiddenField);
// docBody.appendChild(HasNextBadgeMarkupHiddenField);
// docBody.appendChild(HasCurrentBadgeMarkupHiddenField);
docBody.appendChild(HasNextBadgeMarkuDiv)
docBody.appendChild(HasCurrentBadgeMarkupDiv);
docBody.appendChild(ShowProgressBarDiv);
docBody.appendChild(ScoreUpdatedDiv);
docBody.appendChild(GameLevelDiv);
docBody.appendChild(BarEnabledDiv);
docBody.appendChild(GameLevelNameDiv);
docBody.appendChild(CurrentScoreDiv);
docBody.appendChild(progressToolBarDiv);
docBody.appendChild(YuiDiv);
// wire up mouse out to hide either badge on mouse out of tool bar
$('#ProgressToolBar').mouseout(function() {
YAHOO.container.BadgePanel.hide();
});
createBadgeYUI();
WriteProgressBar();
}
function WriteProgressBar() {
var url = '/general/ProgressBarReceiver.aspx?TransferSession=0';
// only poll for new data if Pulse has not been disabled
if (getCookie("PulseOff") != "1")
{
$.ajax({
url: url,
async: true,
dataType: 'json',
success: function (json) {
$('#CurrentScore').text(json.CurrentScore); // the current score as a string, only in 10s
$('#ProgressBarText').text(json.CurrentLevelName); // the current game level name with stats(percentage achieved until next level)
$('#NextProgressBarText').text(json.NextLevelName); // the name of the next level if one exists
$('#IsProgressBarEnabled').text(json.IsProgressBarEnabled);
$('#GameLevel').text(json.LevelName);
$('#ScoreUpdated').text(json.blnUserAchievedNewScore);
$('#ShowProgressBarAlways').text(json.ShowProgressBarAlways);
$('#HasCurrentBadgeMarkup').text(json.HasCurrentBadgeMarkup);
$('#HasNextBadgeMarkup').text(json.HasNextBadgeMarkup);
var progress = $("#CurrentScore").text();
var intProgress = parseInt(progress);
var isScoreUpdated = $("#ScoreUpdated").text();
var showProgressBarAlways = $("#ShowProgressBarAlways").text();
var IsProgressBarEnabled = $("#IsProgressBarEnabled").text();
var hasCurrentBadgeMarkup = $("#HasCurrentBadgeMarkup").text();
var hasNextBadgeMarkup = $("#HasNextBadgeMarkup").text();
$("#ProgressToolBar").hide();
$("#ProgressBarText").hide();
$("#progressBar").hide();
$("#NextProgressBarText").hide();
//add onmouseover/onhover to ProgressBarText conditionally
if ((hasCurrentBadgeMarkup == "False") | (hasCurrentBadgeMarkup == "false")) {
$("#ProgressBarText").remove('onmouseover', 'showBadge(this)');
}
//add onmouseover/onhover NextProgressBarText conditionally
if ((hasNextBadgeMarkup == "False") | (hasNextBadgeMarkup == "false")) {
$("#NextProgressBarText").remove('onmouseover', 'showBadge(this)');
}
// check to see if there is a value for game level, if there isn't then no use for progress bar
var gameLevel = $("#GameLevel"); // this value only holds the text of the actual game level name with no statistics
var ProgressBarText = $("#ProgressBarText"); // this holds game level name with current percent achieved, set to invisible already
var ProgressBar = $("#progressBar");
var ProgressToolBar = $("#ProgressToolBar");
var NextProgressBarText = $("#NextProgressBarText");
// Don't show if progress bar isn't enabled
if (IsProgressBarEnabled.toLowerCase() == "true") {
if ((!gameLevel.text()) && (!NextProgressBarText.text())) {
// hide the tool bar, no game levels exist
ProgressToolBar.hide();
ProgressBarText.hide();
ProgressBar.hide();
NextProgressBarText.hide();
}
else {
// else if it's active set the value
var ProgressBar = $("#progressBar");
var ProgressToolBar = $("#ProgressToolBar");
$("div.progressBar").progressbar({
value: intProgress
});
$("#profileProgressBar").progressbar({
value: intProgress
});
if ((isScoreUpdated == "True") | (isScoreUpdated == "true")) {
// set the animation acccording to user preference on progress bar display
if (showProgressBarAlways.toLowerCase() == "false") {
ProgressBarText.show();
ProgressBar.show();
NextProgressBarText.show();
ProgressToolBar.show(3000).fadeIn(4000).delay(5000);
ProgressToolBar.hide(2000).fadeOut(2000);
}
else // it's set to always active
{
ProgressBarText.show();
ProgressBar.show();
NextProgressBarText.show();
ProgressToolBar.show();
}
}
}
}
},
complete: function () {
return true;
}
});
}
pollForProgress();
}
function pollForProgress(retrys) {
// poll for new progress bar data, new score
try {
//check for new conversations every 60 seconds
ProgressID = setTimeout(function() { WriteProgressBar() }, 60000);
}
catch (e) {
//retry 3 times before giving up
if (isNaN(retrys)) retrys = 0;
if (retrys < 3) {
retrys++;
ProgressID = setTimeout(function() { WriteProgressBar(retrys) }, 1000);
}
}
}
function createBadgeYUI() {
YAHOO.namespace("container");
function YAHOOinitBadgePanel() {
YAHOO.container.BadgePanel = new YAHOO.widget.Panel("BadgePanel", { visible: false,
iframe: true,
constraintoviewport: true,
close: false,
draggable: false,
modal: false,
underlay: 'shadow'
});
YAHOO.container.BadgePanel.render();
}
YAHOO.util.Event.onDOMReady(YAHOOinitBadgePanel);
}
function showBadge(Badge) {
var currentId = $(Badge).attr('id');
var url = '/general/GameLevelBadgeReciever.aspx?selected=' + $(Badge).attr('id');
$.ajax({
url: url,
async: true,
dataType: 'json',
success: function(json) {
if (json.SelectedBadge) {
$('#BadgePanelBody').html(json.SelectedBadge);
//IE hack: underlay size does not change with panel size; resize it now
if (document.all) YAHOO.container.BadgePanel.sizeUnderlay();
if (document.all) YAHOO.container.BadgePanel.sizeUnderlay();
YAHOO.container.BadgePanel.cfg.setProperty('context', [currentId, 'tl', 'bl']);
YAHOO.container.BadgePanel.show();
}
},
complete: function() {
return true;
}
});
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// End progress bar functions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function StickyFooterWithAlertBar(ToolBar) {// if the user is an admin and chatting place the chat bar above the admin bar
if (document.compatMode == 'BackCompat') {// Are we in quirks mode?
$(function() {
positionFooter();
function positionFooter() {
$("#TopToolBar").css({ position: "absolute", top: ($(window).scrollTop() + $(window).height() - 45) + "px" })
}
$(window)
.scroll(positionFooter)
.resize(positionFooter)
});
}
else {// standards mode thus position fixed works
$(ToolBar).css({
position: 'fixed',
bottom: '21px'
});
}
}
function StickyFooter(ToolBar) {// Chat bar with no active admin bar
// The css class for CSS1Compat aka standards is already set so nothing will happen unless in quirks aka BackCompat
if (document.compatMode == 'BackCompat') {
$(function() {
positionFooter();
function positionFooter() {
ToolBar.css({ position: "absolute", top: ($(window).scrollTop() + $(window).height() - ToolBar.height()) + "px" })
}
$(window)
.scroll(positionFooter)
.resize(positionFooter)
});
}
}
function HideOnScroll(ToolBar) {
var $menu = ToolBar;
var opacity = $menu.css("opacity");
var scrollStopped;
var fadeInCallback = function() {
if (typeof scrollStopped != 'undefined') {
clearInterval(scrollStopped);
}
scrollStopped = setTimeout(function() {
$menu.animate({ opacity: 1 }, "fast");
}, 100);
}
$(window).scroll(function() {
if (!$menu.is(":animated") && opacity == 1) {
$menu.animate({ opacity: 0 }, "fast", fadeInCallback);
} else {
fadeInCallback.call(this);
}
});
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Category auto complete functions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function QuickSearchForm_DoSubmit()
{
var QuickSearchForm = document.getElementById('QuickSearchForm');
if(QuickSearchForm)
{
ClearDefaultValue(QuickSearchForm.bst);
QuickSearchForm.submit();
}
return false;
}
function QuickSearchForm_OnFocus()
{
var element = document.getElementById("QuickSearchForm_bst");
ClearDefaultValue(element);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// End category auto complete functions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function BlinkTopAlertBar(HowManyTimes, i)
{
if (isNaN(i)) i = 1;
if (i % 2 == 0) {
document.getElementById('TopAlertBarText').style.display = '';
} else {
document.getElementById('TopAlertBarText').style.display = 'none';
}
if (i < (HowManyTimes * 2)) {
i++;
m_BlinkTopAlertBarTID = setTimeout(function() { BlinkTopAlertBar(HowManyTimes, i) }, 300);
}
}
function CheckCityStateZip(oForm, sCityField, sZipField, sStateField, sStateList) {
if (eval('oForm.' + sCityField).value == '') return false;
if (eval('oForm.' + sZipField).value == '') return false;
if (eval('oForm.' + sStateField).value == '') {
var oStateList = eval('oForm.' + sStateList);
if (oStateList.options[oStateList.selectedIndex].value == '') return false;
}
return true;
}
function CheckMultipartForms(blnAllowSubmit) {
if (blnAllowSubmit) return;
if (!document.forms.length > 0) return;
var blnFoundOne = false;
for (var i = 0; i < document.forms.length; i++) {
if (document.forms[i].enctype.toLowerCase() == 'multipart/form-data') {
blnFoundOne = true;
document.forms[i].onsubmit = function() { return false; }
}
}
if (blnFoundOne) alert('We\'\re sorry, file uploads and forms containing file uploads\nhave been temporarily disabled. Please check back in a few minutes.');
}
function DoUploadProgress(sender) { //does the hidden field exist for storing the progress-id?
return true; //The progress bar doesn't work for AWS, return true and do nothing more
var sUid = '', sPid = '';
if (sender.UploadID) {
sUid = sender.UploadID.value;
} else if (sender.ProgressID) {
sPid = sender.ProgressID.value;
} else {
return true;
}
//are there any files being uploaded?
var fields = sender.elements;
var bHasFile = false;
FieldLoop: for (var i = 0; i < fields.length; i++) {
if (fields[i].type.toLowerCase() == 'file' && fields[i].value != '') {
bHasFile = true;
break FieldLoop;
}
}
if (!bHasFile) return true;
var sAction = sender.action;
var rx = new RegExp("\\?.+=", "i");
if (rx.test(sAction)) {
sAction += '&';
} else {
rx.compile("\\?$", "i");
if (!rx.test(sAction)) sAction += '?';
}
var sIdArg = sUid.length > 0 ? 'uid=' + sUid : 'pid=' + sPid;
sAction += sIdArg;
sender.action = sAction;
openPopup('/general/upload_progress.asp?' + sIdArg, 'UploadProgress', 'status,toolbar=false', 250, 120);
return true;
}
function openCsvExport(unicode, alternateUrl, extraQueryArgs) {
var Url = alternateUrl == null ? '/admin/database/csv_export.asp' : alternateUrl;
if (extraQueryArgs == null) extraQueryArgs = '';
openPopup(Url + '?unicode=' + unicode.toString() + '&' + extraQueryArgs.toString(), '_blank', 'resizable,status,toolbar=false', 350, 150);
return false;
}
//address-manager window functions
function openAddressManager(AddrMgrUrl, MasterElementId, QueryArgs) {
m_winAddressManager = returnPopup(AddrMgrUrl + '?OpenerMasterElementId=' + MasterElementId + '&' + QueryArgs, 'AddressManager', 'resizable,scrollbars,status,toolbar=false', 660, 660);
m_winAddressManager.focus()
return false;
}
function closeAddressManager() {
try { m_winAddressManager.close(); } catch (e) { };
}
function openMugshotPopup(Url) {
return openPopup(Url, 'MemberMugshot', 'resizable,scrollbars,status,toolbar=false', 537, 405);
}
function openPrintView(Url, OpenDialog, QueryArgs) {
openPopup(Url + "?PrintView=1&OpenDialog=" + OpenDialog + "&" + QueryArgs,
"PrintView", "menubar,scrollbars,status,toolbar=false", 640, 640);
return false;
}
//begin dynamic help functions
var m_blnInlineHelpIsOn = false;
function switchInlineHelpDisplay() {
if (m_blnInlineHelpIsOn) {
doInlineHelpOff();
} else {
doInlineHelpOn();
}
return false;
}
function doInlineHelpOn() {
//show inline help areas
setInlineHelpDisplay(true);
//switch toggle link
dhtmlDisplay('InlineHelpLinkShow', 'none');
dhtmlDisplay('InlineHelpLinkHide', '');
//set current state
m_blnInlineHelpIsOn = true;
//preserve current state in cookie
setInlineHelpCookie();
}
function doInlineHelpOff() {
//hide inline help areas
setInlineHelpDisplay(false);
//switch toggle link
dhtmlDisplay('InlineHelpLinkShow', '');
dhtmlDisplay('InlineHelpLinkHide', 'none');
//set current state
m_blnInlineHelpIsOn = false;
//preserve current state in cookie
setInlineHelpCookie();
}
function setInlineHelpCookie() {
if (document.cookie) { //set cookie expiry at 1 year
var datExpires = new Date();
datExpires.setTime(datExpires.getTime() + 31536000000);
if (m_blnInlineHelpIsOn) {
document.cookie = 'InlineHelpDisplay=InlineHelpDisplayOn; expires=' + datExpires.toGMTString() + '; path=/';
} else {
document.cookie = 'InlineHelpDisplay=InlineHelpDisplayOff; expires=' + datExpires.toGMTString() + '; path=/';
}
}
}
function setInlineHelpDisplay(visible) {
setInlineHelpDisplayItems(document.anchors, visible);
setInlineHelpDisplayItems(document.links, visible);
}
function setInlineHelpDisplayItems(items, visible) {
for (var i = 0; i < items.length; i++) {
if (items[i].className.toLowerCase() == 'inlinehelp') {
if (items[i].href == '') {
items[i].style.display = visible ? 'inline' : 'none';
} else {
items[i].style.display = visible ? 'inline' : 'none';
items[i].style.textDecoration = 'underline';
}
}
}
}
function initInlineHelpDisplay() {
if ((document.cookie) && (document.cookie.toString().indexOf('InlineHelpDisplayOff') >= 0)) {
doInlineHelpOff();
} else {
doInlineHelpOn()
}
}
function mediaPopup(theURL) {
openPopup(theURL, 'winMediaPopup', 'status,toolbar=false', 622, 496);
return false;
}
function AlertAppUpdate() {
if (confirm('There have been updates to the\nsystem since your last visit!\n\nClick OK to review the latest features, \nenhancements and bug fixes.'))
location.href = '/admin/client_services/updates.asp';
}
function ConfirmSignIn(strMemberName) {
return confirm('You will now be signed in as ' + strMemberName + '. \n\nAre you sure you want to continue? ');
}
//search form functions
function SearchForm_q_OnKeyPress(e, sender) {
if (getkey(e) == 13) {
return SearchForm_Validate(sender);
}
return true;
}
function SearchForm_Validate(sender, element) {
if (!element) element = sender.form.q;
var sVal = element.value;
if (sVal == '' || /^[\s]+$/.test(sVal)) {
alert('Please enter some search criteria. ');
element.focus();
return false;
}
return true;
}
function StartNewSearch(FormId) {
var SearchForm = document.getElementById(FormId);
if (SearchForm) {
SearchForm.q.value = '';
SearchForm.style.display = '';
SearchForm.q.focus();
}
return false;
}
function FilterSearchByCatalog(CatalogEnum) {
var win = (parent) ? parent : self;
var sQuery = win.location.search.replace(/\&?c=[^\&]*\&?/, "");
if (sQuery.length == 0)
{
sQuery = '?';
} else if (sQuery != '?')
{
sQuery += '&';
}
win.location.href = win.location.pathname + sQuery + "c=" + CatalogEnum.toString();
return false;
}
function FilterIframeSearchCatalog(Catalog, CatalogEnum)
{
// The category filter is an empty span appended to the end of the search box text, it will hold a link that is created in the same manner that the parent page is
// using to create the remove filter link with as is the case with old functionality when you click on a category in the search results description text
// This function is used for the actual links created inside of the iframe window, when you filter by one of these categories "More Results" link, then we will want to show
// the results un filtered, but with the current category
self.location.href = self.location.href + "&c=" + CatalogEnum;
var bSelectedCategory = window.parent.document.getElementById('bCategoryFilter');
bSelectedCategory.innerHTML = " in " + Catalog + "(x)";
}
function emoticon(code, txtarea) {
if ($("#ifRadEditor_strBody").is(":visible")) {
//new RadEditor IFrame is on the page
var $editor = $("#ifRadEditor_strBody").contents().find("body div#RadEditor1_contentDiv");
if ($editor.is(":visible")) {
// design mode
$editor.append(code);
}
else {
// HTML mode
$editor = $("#ifRadEditor_strBody").contents().find("body td#RadEditor1Center iframe").contents().find("body textarea");
$editor.val($editor.val() + code);
}
return;
}
if ((!txtarea) || typeof (txtarea) == 'undefined') {
txtarea = document.frmMessage.strBody;
}
try { oUtil.obj.insertHTML(code); return; } catch (e) { }
try { insertAtCaret(txtarea, code) } catch (e) { }
}
var m_bYuiGenericDialogResult;
var m_sDialogHeaderText = "";
//Two Button (confirm style) dialog
function YuiGenericDialog(Id, BodyText, Callback, TrueText, FalseText, ContainerId, PanelWidth, posX, posY, timeoutSeconds)
{
if (!objectExists(TrueText)) TrueText = 'Yes';
if (!objectExists(FalseText)) FalseText = 'No';
if (!objectExists(PanelWidth)) PanelWidth = '300px';
if (!objectExists(timeoutSeconds)) timeoutSeconds = 0;
var blnCentered = true;
if (objectExists(posX) && objectExists(posY))
{
blnCentered = false;
}
else
{
posX = 0;
posY = 0;
}
var dialog = new YAHOO.widget.SimpleDialog(Id, {
text: BodyText,
iframe: false,
visible: false,
close: false,
draggable: false,
fixedcenter: blnCentered,
constraintoviewport: true,
modal: true,
postmethod: 'none',
underlay: 'shadow',
width: PanelWidth,
x: posX,
y: posY
});
dialog.setHeader("Attention");
if (m_sDialogHeaderText != '') {
dialog.setHeader(m_sDialogHeaderText);
}
//dialog.cfg.setProperty("icon",YAHOO.widget.SimpleDialog.ICON_HELP);
var aButtons = new Array();
if (TrueText.length > 0) {
aButtons[0] = {
text: TrueText, handler: function () {
m_bYuiGenericDialogResult = true;
this.hide();
Callback();
}, isDefault: true
};
}
if (FalseText.length > 0) {
aButtons[1] = {
text: FalseText, handler: function () {
m_bYuiGenericDialogResult = false;
this.hide();
Callback();
}
};
}
dialog.cfg.queueProperty("buttons", aButtons);
if (!objectExists(ContainerId)) ContainerId = "PageBase_RaiseAlert";
var container = document.getElementById(ContainerId);
if (!container) return;
m_bYuiGenericDialogResult = null;
dialog.render(container);
dialog.show();
if (timeoutSeconds > 0) setTimeout(function () { dialog.hide(); }, Math.round(timeoutSeconds * 1000));
}
function YuiGenericDialogCallback_ButtonClick(button) {
if (m_bYuiGenericDialogResult) {
button.onclick = function() { return true; }
button.click();
}
}
//call as a replacement for JavaScript Confirm (i.e. Submit
function YUIConfirm(msg, yesaction) {
YuiGenericDialog("confirm",
msg,
yesaction
);
}
function YUIConfirmCustomHeader(msg, yesaction, headertext) {
m_sDialogHeaderText = headertext;
YuiGenericDialog("confirm",
msg,
yesaction
);
}
function YUIConfirmCustomHeaderCustomPosition(msg, yesaction, headertext, posX, posY)
{
m_sDialogHeaderText = headertext;
YuiGenericDialog("confirm", msg, yesaction, null, null, null, null, posX, posY);
}
//One button (alert style) dialog
function YuiGenericAlert(Id, BodyText, Callback, ButtonText, ContainerId, PanelWidth) {
if (!objectExists(ButtonText)) ButtonText = 'OK';
if (!objectExists(PanelWidth)) PanelWidth = '300px';
var dialog = new YAHOO.widget.SimpleDialog(Id, {
text: BodyText,
iframe: false,
visible: false,
close: false,
draggable: false,
fixedcenter: true,
constraintoviewport: true,
modal: true,
postmethod: 'none',
underlay: 'shadow',
width: PanelWidth
}
);
dialog.setHeader("Attention");
//dialog.cfg.setProperty("icon", YAHOO.widget.SimpleDialog.ICON_HELP);
dialog.cfg.queueProperty("buttons", [
{ text: ButtonText, handler: function() {
m_bYuiGenericDialogResult = true;
this.hide();
Callback();
}, isDefault: true
}
]);
if (!objectExists(ContainerId)) ContainerId = "PageBase_RaiseAlert";
var container = document.getElementById(ContainerId);
if (!container) return;
m_bYuiGenericDialogResult = null;
dialog.render(container);
dialog.show();
}
// Page Alert - Mimics the Page Alert temporary dialog box that appears, but this one can be called from javascript.
function ShowPageAlert(message)
{
var container = document.getElementById('PageBase_RaiseAlert');
if (container)
{
var AlertID = new Date().getTime();
if ((document.cookie) && (document.cookie.toString().indexOf(AlertID) < 0))
{
document.cookie = 'AlertID=' + AlertID;
PageBase_RaiseAlert_Dialog = new YAHOO.widget.SimpleDialog("PageBase_RaiseAlert_Dialog", {
text: message,
iframe: false,
visible: true,
close: true,
draggable: true,
modal: false,
underlay: 'shadow',
width: '270px',
x: 5,
y: 5
});
PageBase_RaiseAlert_Dialog.setHeader("Attention");
PageBase_RaiseAlert_Dialog.cfg.setProperty("icon", YAHOO.widget.SimpleDialog.ICON_WARN);
PageBase_RaiseAlert_Dialog.render(container);
var PageBase_RaiseAlert_Tid = setTimeout('PageBase_RaiseAlert_Dialog.hide();', 7000);
}
}
}
//added type in order to color the alert accordingly.
//Type values: info, success, warning, danger. Default: info
function RaiseAlert(message, type)
{
//lowercase
type = typeof type !== 'undefined' ? type.toLowerCase() : "info";
var icon = "fa-bullhorn";
switch (type) {
case "warning": icon = "fa-bullhorn";
break;
case "danger": icon = "fa-flag";
break;
case "success": icon = "fa-check";
break;
default:
type = "info";
break;
}
if (!$("#jsPageAlert").length) {
$("").prependTo("BODY"); //
};
var markup =
"
" +
"" +
"" + message +
"
";
$("#jsPageAlert").html(markup);
if (document.cookie && document.cookie.toString().indexOf(AlertID) < 0)
{
var AlertID = Date.now();
document.cookie = 'AlertID=' + AlertID;
}
// Auto-dismiss after 5 seconds
var toggleAlert = function()
{
$('.anchored-alert-top').removeClass('fadeInDown').addClass('fadeOutUp');
}
setInterval(toggleAlert, 5000);
// Enable dismiss by clicking anywhere on the page, except on the alert window
$(document).click(function(event)
{
if (!$(event.target).hasClass('anchored-alert-top'))
{
$('.anchored-alert-top').removeClass('fadeInDown').addClass('fadeOutUp');
}
});
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// common functions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function getCurrentTime() {
var now = new Date();
return now.getTime();
}
function fixnewlines(val) {
// Adjust newlines so can do correct character counting for MySQL. MySQL counts a newline as 2 characters.
if (val.indexOf('\r\n') != -1)
; // this is IE on windows. Puts both characters for a newline, just what MySQL does. No need to alter
else if (val.indexOf('\r') != -1)
val = val.replace(/\r/g, "\r\n"); // this is IE on a Mac. Need to add the line feed
else if (val.indexOf('\n') != -1)
val = val.replace(/\n/g, "\r\n"); // this is Firefox on any platform. Need to add carriage return
else
; // no newlines in the textarea
return val;
}
function objectExists(o) {
if (typeof o == 'undefined' || o == null) return false;
return true;
}
function isEmpty(val) {
return (!val || val == null || val.toString() == '');
}
function replaceAccents(sVal) {
var RetVal = new String(sVal);
var regExps = [/[\xC0-\xC5]/g,
/[\xE0-\xE5]/g,
/[\xC8-\xCB]/g,
/[\xE8-\xEB]/g,
/[\xCC-\xCF]/g,
/[\xEC-\xEF]/g,
/[\xD2-\xD6]/g,
/[\xF2-\xF6]/g,
/[\xD9-\xDC]/g,
/[\xF9-\xFC]/g,
/\xDD/g, /\xFD/g,
/\xC7/g, /\xE7/g,
/\xD1/g, /\xF1/g];
var repChar = ['A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U', 'u', 'Y', 'y', 'C', 'c', 'N', 'n'];
for (var i = 0; i < regExps.length; i++)
RetVal = RetVal.replace(regExps[i], repChar[i]);
return RetVal;
}
function replaceReturns(sVal) {
var RetVal = fixnewlines(sVal.toString());
return RetVal.replace(/\r\n/g, ' ');
}
function insertAtCaret(obj, text) {
if (document.selection) {
obj.focus();
var orig = obj.value.replace(/\r\n/g, "\n");
var range = document.selection.createRange();
if (range.parentElement() != obj) {
return false;
}
range.text = text;
var actual = tmp = obj.value.replace(/\r\n/g, "\n");
for (var diff = 0; diff < orig.length; diff++) {
if (orig.charAt(diff) != actual.charAt(diff)) break;
}
for (var index = 0, start = 0;
tmp.match(text)
&& (tmp = tmp.replace(text, ""))
&& index <= diff;
index = start + text.length
) {
start = actual.indexOf(text, index);
}
} else if (obj.selectionStart) {
var start = obj.selectionStart;
var end = obj.selectionEnd;
obj.value = obj.value.substr(0, start)
+ text
+ obj.value.substr(end, obj.value.length);
}
if (start != null) {
setCaretTo(obj, start + text.length);
} else {
obj.value += text;
}
}
function setCaretTo(obj, pos) {
if (obj.createTextRange) {
var range = obj.createTextRange();
range.move('character', pos);
range.select();
} else if (obj.selectionStart) {
obj.focus();
obj.setSelectionRange(pos, pos);
}
}
function stripHtml(sVal) {
return sVal.toString().replace(/<[\?\/!A-Za-z]+[^<>]*>?/ig, ' ');
}
function urlDecode(sVal) {
if (isEmpty(sVal)) return sVal;
return decodeURIComponent(sVal.toString()).replace(/\+/g, ' ');
}
function setCookie(name, value, path, expiredays) {
var sCookie = name + '=' + escape(value);
if (expiredays && typeof (expiredays) != 'undefined') {
var exdate = new Date();
exdate.setDate(exdate.getDate() + expiredays);
sCookie += ('; expires=' + exdate.toGMTString());
}
if (path && typeof (path) != 'undefined') sCookie += ('; path=' + path);
document.cookie = sCookie;
}
function getCookie(name) {
if ((!document.cookie) || document.cookie.length == 0) return '';
var iStart = document.cookie.indexOf(name + '=');
if (iStart >= 0) {
iStart += (name.length + 1);
var iEnd = document.cookie.indexOf(";", iStart);
if (iEnd < 0) iEnd = document.cookie.length;
return unescape(document.cookie.substring(iStart, iEnd));
}
return '';
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// helpers for wiring-up event handlers
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function addEventHandler_OnLoad(oFunc) {
var oldHandler = window.onload;
if (typeof window.onload != 'function') {
window.onload = oFunc;
} else {
window.onload = function() {
oldHandler();
oFunc();
}
}
}
function addEventHandler_OnUnload(oFunc) {
var oldHandler = window.onunload;
if (typeof window.onunload != 'function') {
window.onunload = oFunc;
} else {
window.onunload = function() {
oldHandler();
oFunc();
}
}
}
function addEventHandler_OnLoadAndUnload(oFunc) {
addEventHandler_OnLoad(oFunc);
addEventHandler_OnUnload(oFunc);
}
function addEventHandler_OnSubmit(oForm, oFunc) {
var oldHandler = oForm.onsubmit;
if (typeof oForm.onsubmit != 'function') {
oForm.onsubmit = oFunc;
} else {
oForm.onsubmit = function() {
oldHandler();
oFunc();
}
}
}
function addEventHandler_OnSubmitChained(oForm, oFunc) {
var oldHandler = oForm.onsubmit;
if (typeof oForm.onsubmit != 'function') {
oForm.onsubmit = oFunc;
} else {
oForm.onsubmit = function() {
return oldHandler() && oFunc();
}
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// window functions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
var blnRefreshWindow = false;
var blnCallBackRefresh = false;
function getWinSize() {
var iWinW = 0;
var iWinH = 0;
if (typeof (window.innerWidth) != 'undefined') {
iWinW = window.innerWidth;
iWinH = window.innerHeight;
} else {
var d = document;
if (d.documentElement && typeof (d.documentElement.clientWidth) != 'undefined' &&
d.documentElement.clientWidth !== 0) {
iWinW = d.documentElement.clientWidth;
iWinH = d.documentElement.clientHeight;
} else if (document.body && typeof (d.body.clientWidth) != 'undefined') {
iWinW = d.body.clientWidth;
iWinH = d.body.clientHeight;
}
}
var aRetVal = new Array(1);
aRetVal[0] = iWinW;
aRetVal[1] = iWinH;
return aRetVal;
}
function windowIsOpen(objWindow) {
var blnIsOpen = false;
if (typeof (objWindow) == 'object') {
if (!objWindow.closed) {
blnIsOpen = true;
}
}
return blnIsOpen;
}
function setOpenerRefresh() {
if (windowIsOpen(opener)) {
opener.blnRefreshWindow = true;
}
}
function reloadSelf() {
var now = new Date();
var newHref = location.protocol + '//' + location.hostname + location.pathname;
var qString = location.search.replace(/\&?reloadtime=[^\&]*\&?/, '');
if (qString.length == 0) {
qString = '?'
} else if (qString != '?') {
qString += '&';
}
newHref += qString + 'reloadtime=' + now.getTime();
location.href = newHref;
}
function refreshOpener(strDefaultURL, blnCloseMe) {
var blnExists = false;
if (windowIsOpen(opener)) {
if (opener.blnCallBackRefresh)
{
opener.SubmitRefresh();
}
else
if (opener.blnRefreshWindow == true) {
var now = new Date();
var newHref = opener.location.protocol + '//' + opener.location.hostname + opener.location.pathname;
var qString = opener.location.search.replace(/\&?reloadtime=[^\&]*\&?/, '');
if (qString.length == 0) {
qString = '?'
} else if (qString != '?') {
qString += '&';
}
newHref += qString + 'reloadtime=' + now.getTime();
opener.location.href = newHref;
opener.focus();
}
blnExists = true;
}
if (blnExists == false) {
window.open(strDefaultURL);
blnCloseMe = true;
}
if (blnCloseMe == true) window.close(self);
}
function openerLocation(strLocation, blnCloseMe) {
if (windowIsOpen(opener)) {
opener.location.href = strLocation;
if (blnCloseMe) opener.focus();
} else {
window.open(strLocation);
}
if (blnCloseMe) window.close(self);
}
function focusPopup(objPopup, theURL, winName, features, width, height) {
var blnIsOpen = true;
if (typeof (objPopup) != 'object') {
blnIsOpen = false;
} else if (objPopup.closed) {
blnIsOpen = false;
}
if (blnIsOpen == false) {
objPopup = returnPopup(theURL, winName, features, width, height);
}
objPopup.focus();
return objPopup;
}
function goToUrlOnClick(Url) {
location.href = Url;
return false;
}
function goToUrlOnClickTargetParent(Url) {
parent.location.href = Url;
return false;
}
function openPopup(theURL, winName, features, width, height) {
var objPopup = returnPopup(theURL, winName, features, width, height);
objPopup.focus();
}
function returnPopup(theURL, winName, features, width, height) {
var winWidth = width;
var winHeight = height;
var strWinSize = ",width=" + winWidth + ",height=" + winHeight;
if (window.screen) {
var winPosL = (screen.availWidth - winWidth) / 2;
var winPosT = (screen.availHeight - winHeight) / 2;
strWinSize += ",left=" + winPosL + ",screenX=" + winPosL + ",top=" + winPosT + ",screenY=" + winPosT;
}
return window.open(theURL, winName, features + strWinSize);
}
function closePopup() {
window.close(self);
}
function setWinStatus(value) {
window.status = value;
return true;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// form functions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function addOptionToSelectList(DomID, value) {
var SelectList = document.getElementById(DomID);
SelectList.options[SelectList.length] = new Option(value, value);
}
function removeSelectedOption(DomID) {
var SelectList = document.getElementById(DomID);
SelectList.options[SelectList.selectedIndex] = null;
}
function addHiddenInputToForm(form, name, value) {
var newInput = document.createElement('INPUT');
if (document.all) {
newInput.type = 'hidden';
newInput.id = name;
newInput.name = name;
newInput.value = value;
} else {
newInput.setAttribute('type', 'hidden');
newInput.setAttribute('id', name);
newInput.setAttribute('name', name);
newInput.setAttribute('value', value);
}
form.appendChild(newInput);
}
function ClearDefaultValue(o) {
if (o && o.value && o.defaultValue && o.value.toLowerCase() == o.defaultValue.toLowerCase()) o.value = '';
}
function checkRadioByValue(oRadio, value) {
if (oRadio) {
if (oRadio.length > 0) {
for (var i = 0; i < oRadio.length; i++)
oRadio[i].checked = (oRadio[i].value == value.toString());
} else {
oRadio.checked = (oRadio.value == value.toString());
}
}
}
function getCheckedRadioValue(oRadio) {
if (oRadio) {
if (oRadio.length > 0) {
for (var i = 0; i < oRadio.length; i++) {
if (oRadio[i].checked) return oRadio[i].value;
}
} else if (oRadio.checked) {
return oRadio.value;
}
}
return null;
}
function getSelectedText(elmnt) {
if (elmnt && elmnt.options) {
return elmnt.options[elmnt.selectedIndex].text;
}
return '';
}
function getSelectedTextById(elementId) {
var elmnt = document.getElementById(elementId);
return getSelectedText(elmnt);
}
function getSelectedValue(elmnt) {
if (elmnt && elmnt.options) {
return elmnt.options[elmnt.selectedIndex].value;
}
return '';
}
function getSelectedValueById(elementId) {
var elmnt = document.getElementById(elementId);
return getSelectedValue(elmnt);
}
function selectOptionByValue(oSelect, value) {
if (oSelect) {
for (var i = 0; i < oSelect.length; i++) {
if (oSelect.options[i].value == value.toString()) {
oSelect.selectedIndex = i;
break;
}
}
}
}
function verifyMsg(jsStrURL, jsStrMsg) {
if (confirm(jsStrMsg)) {
this.window.location = jsStrURL;
return true;
}
}
function CheckALL(objCheckbox) {
if (objCheckbox) {
var len = objCheckbox.length;
if (len > 0) {
var i = 0;
for (i = 0; i < len; i++) {
objCheckbox[i].checked = true;
}
} else {
objCheckbox.checked = true;
}
}
}
function UnCheckALL(objCheckbox) {
if (objCheckbox) {
var len = objCheckbox.length;
if (len > 0) {
var i = 0;
for (i = 0; i < len; i++) {
objCheckbox[i].checked = false;
}
} else {
objCheckbox.checked = false;
}
}
}
function formFocus(strFormname, strElement) {
var objE = eval('document.' + strFormname + '.' + strElement);
if (objE) objE.focus();
}
function buildHumanSQL(objElement, strHeadline) {
var inputLocal = objElement;
var strSQLHuman = '' + strHeadline + '\n';
strSQLHuman += '
\n';
if (inputLocal) {
var len = inputLocal.length;
var i = 0;
for (i = 0; i < len; i++) {
if (inputLocal.options[i].selected) {
strSQLHuman += '
' + inputLocal.options[i].text + '
\n';
}
}
}
strSQLHuman += '
'
objElement.form.txt_sqlHuman.value = strSQLHuman;
return true;
}
function ClickOnCrKeyPress(e, button) {
if (getkey(e) == 13) {
button.click();
return false;
}
else return true;
}
function DoOnCrKeyPress(e, oFunc) {
if (getkey(e) == 13) {
oFunc();
return false;
}
else return true;
}
function SubmitOnCrKeyPress(e, sender) {
if (getkey(e) == 13) {
sender.form.submit();
return false;
}
else return true;
}
function VoidOnCrKeyPress(e) {
return (getkey(e) != 13);
}
function getkey(e) {
if (window.event)
return window.event.keyCode;
else if (e)
return e.which;
else
return null;
}
function confirmDelete(objForm, strElement, strValue) {
var ItemRow = document.getElementById(strValue.toString());
var strPrevClass = '';
if (ItemRow) {
strPrevClass = ItemRow.className;
ItemRow.className = 'delitem';
}
if (confirm('Are you sure you want to delete the selected item? ')) {
eval('objForm.' + strElement).value = strValue;
return true;
}
else {
if (ItemRow) ItemRow.className = strPrevClass;
return false;
}
}
function InlineDelete_Submit(sender, keyfield, id) {
return confirmDelete(sender.form, keyfield, id);
}
function InlineItem_Delete(sender, ItemID) {
return confirmDelete(sender.form, 'ItemID', ItemID);
}
//adds a new option to a userlist element
function UserListAdd(sender, ID, AllowComma, DefaultValue) {
var SelectList = eval('sender.form.' + ID + '_select');
var UserInput = eval('sender.form.' + ID + '_input');
if (SelectList && UserInput) {
var val = stripHtml(UserInput.value.toString());
if (!AllowComma) val = val.replace(/,/g, '');
if (val != '') {
SelectList.options[SelectList.length] = new Option(val, val);
RebuildUserList(sender.form, ID);
}
if (DefaultValue != null) UserInput.value = DefaultValue;
try { //IE throws an exception if the focus() method of an invisible object is called
UserInput.focus();
} catch (e) { };
}
}
//removes the selected option from a userlist element
function UserListRemove(sender, ID) {
var SelectList = eval('sender.form.' + ID + '_select');
if (SelectList) {
SelectList.options[SelectList.selectedIndex] = null;
RebuildUserList(sender.form, ID);
}
}
//rebuilds the hidden value of a userlist element
function RebuildUserList(form, ID) {
var HiddenInput = eval('form.' + ID);
if (!HiddenInput) {
addHiddenInputToForm(form, ID, '');
HiddenInput = eval('form.' + ID);
}
HiddenInput.value = '';
var SelectList = eval('form.' + ID + '_select');
if (SelectList) {
for (var i = 0; i < SelectList.length; i++)
HiddenInput.value += SelectList.options[i].value + '\r\n';
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// DHTML display functions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function adjustIFrameHeight(DomID, Height) {
var frame = document.getElementById(DomID);
var frameDoc = getIFrameDoc(DomID);
if (frameDoc == null) return;
if (Height)
{
frame.height = Height;
}
else
{
frame.height = frameDoc.body.offsetHeight;
}
}
function adjustIFrameHeight300(DomID) {
var frame = document.getElementById(DomID);
var frameDoc = getIFrameDoc(DomID);
if (frameDoc == null) return;
frame.height = frameDoc.body.offsetHeight + 350;
}
function getIFrameDoc(FrameID) {
var frame = document.getElementById(FrameID);
var ret = null;
if (frame.contentDocument) { // W3C compliant (Mozilla)
ret = frame.contentDocument;
} else {
// IE
ret = document.frames[FrameID].document;
}
return ret;
}
function ul_onclick(jsObj) {
var i;
var style;
for (i = 0; i < jsObj.children.length; i++) {
style = jsObj.children[i].style;
if (style.display == "none") {
style.display = "";
}
else {
style.display = "none";
}
}
}
function setDisplay(DomId, Value) {
var element = document.getElementById(DomId);
if (element) element.style.display = Value;
return false;
}
function switchDisplay(strDomID) {
var CssStyle = document.getElementById(strDomID).style;
if (CssStyle) {
if (CssStyle.display == '') {
CssStyle.display = 'none';
}
else {
CssStyle.display = '';
}
setCssDisplayCookie(strDomID);
}
return false;
}
function switchDisplayToggle(parentId, childOn, childOff) {
var CssStyle = document.getElementById(parentId).style;
if ((CssStyle) && (CssStyle.display == '')) {
dhtmlDisplay(childOff, '');
dhtmlDisplay(childOn, 'none');
}
else {
dhtmlDisplay(childOff, 'none');
dhtmlDisplay(childOn, '');
}
return false;
}
function getCssDisplayCookie(domId) {
if (document.cookie) {
var CssStyle = document.getElementById(domId).style;
if ((CssStyle) && (document.cookie.toString().indexOf(domId + 'DisplayOn') < 0)) {
CssStyle.display = 'none';
}
else {
CssStyle.display = '';
}
}
}
function setCssDisplayCookie(domId) {
if (document.cookie) {
var CssStyle = document.getElementById(domId).style;
if ((CssStyle) && (CssStyle.display == '')) {
document.cookie = domId + 'Display=' + domId + 'DisplayOn';
}
else {
document.cookie = domId + 'Display=' + domId + 'DisplayOff';
}
}
}
function textCounter(field, cntfield, maxlimit) {
var val = fixnewlines(field.value.toString());
var len = val.length;
//if aready too long, trim it before making any adjustments
if (len > maxlimit) {
val = val.substring(0, maxlimit);
len = val.length;
field.value = val;
}
//update 'characters left' counter
cntfield.value = (maxlimit - len);
}
function TextCounter_Window_OnLoad(FormName, InputName, MaxLen) {
var form = eval('document.' + FormName);
var TextInput = eval('form.' + InputName);
TextInput.onkeyup = function() {
textCounter(this, eval('this.form.' + InputName + '_Counter'), MaxLen);
}
textCounter(TextInput, eval('form.' + InputName + '_Counter'), MaxLen);
}
function InitTextCounter(FormName, InputName, MaxLen) {
addEventHandler_OnLoad(function() { TextCounter_Window_OnLoad(FormName, InputName, MaxLen); });
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// DTHML edit functions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function dhtmlDisplay(domID, dVal) {
var element = document.getElementById(domID);
if (element) element.style.display = dVal;
}
function dhtmlFormEdit(objForm, domLEN, domID) {
var styleView;
var styleEdit;
var i = 1;
for (i = 1; i <= domLEN; i++) {
var styleView = document.getElementById('view' + i.toString()).style;
var styleEdit = document.getElementById('edit' + i.toString()).style;
if ((i.toString() == domID.toString()) && (styleView.display == "")) {
styleView.display = "none";
styleEdit.display = "";
intLastOpenRow = i.toString();
} else {
styleView.display = "";
styleEdit.display = "none";
}
}
objForm.reset();
return false;
}
function dhtmlFormSubmit(objForm1, objForm2, domID, sysAction) {
var i = 0;
for (i = 0; i < objForm2.length; i++) {
var objE = eval('objForm1.' + objForm2[i].name + domID);
if (objE) {
if (objE.type == 'checkbox' | objE.type == 'radio') {
if (objE.checked) {
objForm2[i].value = objE.value;
}
} else if (objE.type == 'select') {
var j = 0;
for (j = 0; j < objE.length; j++) {
if (objE.options[i].selected) {
objForm2[i].value = objE.options[j].value;
}
}
} else {
objForm2[i].value = objE.value;
}
}
}
objForm2.sys_id.value = domID;
objForm2.sys_action.value = sysAction;
var blnSubmit;
if (sysAction == 'delete') {
blnSubmit = confirm('Click OK to delete this record.');
} else {
blnSubmit = true;
}
if (blnSubmit) objForm2.submit();
return false;
}
function MaximizeScrollingBlock(DomId) {
var o = document.getElementById(DomId);
if (o) {
o.style.overflow = 'visible';
o.style.height = 'auto';
}
return false;
}
function RestoreScrollingBlock(DomId, Height) {
var o = document.getElementById(DomId);
if (o) {
o.style.overflow = 'auto';
o.style.height = Height;
}
return false;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// "AJAX" functions ;)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function setInnerHtmlFromHttpRequest(Id, Url) {
var xmlhttp = null;
if (window.XMLHttpRequest) { //code for Mozilla, etc.
xmlhttp = new XMLHttpRequest();
} else if (window.ActiveXObject) { //code for IE
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp) { //wire up the event to handle the response on successful load
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.responseText != '') {
var container = document.getElementById(Id);
container.innerHTML = xmlhttp.responseText;
container.style.display = '';
}
}
xmlhttp.open("GET", Url, true);
xmlhttp.send(null);
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// 3rd-party functions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Countdown in Java Script .. Cameron Gregory http://www.bloke.com/
// permission to use and modify as long as you leave these 4 comment
// lines in tact and unmodified.
// http://www.bloke.com/javascript/Countdown/
var clockForm, clockTime, clockTimeout, clockFormat, clockTid, clockRefresh;
function doDate() {
dt = new Date();
if (clockTime != 0) {
v1 = Math.round((clockTime - dt) / 1000);
//add timeout value to time
v1 += Math.round(clockTimeout * 60);
if (v1 <= 0) {
clockForm.date.value = "expired";
//dont set the timer again
}
else {
if (clockFormat == 1)
clockForm.date.value = v1;
else if (clockFormat == 2) {
sec = v1 % 60;
v1 = Math.floor(v1 / 60);
min = v1 % 60;
hour = Math.floor(v1 / 60);
if (sec < 10) sec = "0" + sec;
if (min < 10) min = "0" + min;
if (hour > 0) {
clockForm.date.value = hour + "h " + min + "m " + sec + "s";
} else {
clockForm.date.value = min + "m " + sec + "s";
}
}
else if (clockFormat == 3) {
sec = v1 % 60;
v1 = Math.floor(v1 / 60);
min = v1 % 60;
v1 = Math.floor(v1 / 60);
hour = v1 % 24;
day = Math.floor(v1 / 24);
if (sec < 10) sec = "0" + sec;
if (min < 10) min = "0" + min;
if (hour < 10) hour = "0" + hour;
clockForm.date.value = day + "d " + hour + "h " + min + "m " + sec + "s";
}
else if (clockFormat == 4) {
sec = v1 % 60;
v1 = Math.floor(v1 / 60);
min = v1 % 60;
v1 = Math.floor(v1 / 60);
hour = v1 % 24;
day = Math.floor(v1 / 24);
clockForm.date.value = day + (day == 1 ? "day " : "days ") + hour + (hour == 1 ? "hour " : "hours ") + min + (min == 1 ? "min " : "mins ") + sec + (sec == 1 ? "sec " : "secs ")
}
else {
clockForm.date.value = "invalid format";
}
clockTid = window.setTimeout("doDate()", clockRefresh);
}
}
else
clockForm.date.value = "error";
}
function startCountdown(objForm, time, timeout, format) {
clockForm = objForm;
clockTime = new Date(time);
clockTimeout = timeout;
clockFormat = format;
clockTid = 0;
clockRefresh = 1000;
if (Math.round((clockTime - new Date()) / 1000) < -60) {
//clock is too far out of sync
clockForm.date.value = "unknown";
}
else {
clockTid = window.setTimeout("doDate()", clockRefresh);
}
}
//shift all the characters in the inval by shiftval characters from the charset
// example: "cat", 2, "abcdefghijklmnopqrstuvwxyz"
// would become "ecv"
// if a character is not found in charset, it is untouched.
//if a shift operation goes out of bounds, it will roll to the other side of charset
function CharShiftDecrypt(strInVal, shiftval, shiftCharSet) {
var strInString = new String(strInVal);
var intInString = strInString.length;
var strCharSet = new String(shiftCharSet);
var intCharSetLen = strCharSet.length;
var strOutVal = new String('');
var nextchar, nextindex, ascii_nextchar, i;
//for each character
for (i = 0; i < intInString; i++) {
// grab the next character to encrypt
nextchar = strInString.substr(i, 1);
//look it up in charset
nextindex = strCharSet.indexOf(nextchar, 0)
if (nextindex >= 0) { //found it
nextindex = (nextindex - shiftval) % intCharSetLen // modulo this so can stay in bounds for next operation
//check bounds of nextindex
if (nextindex < 0) {
nextindex = nextindex + intCharSetLen //wrap around to high end of charset
}
else if (nextindex >= intCharSetLen) { //this wont happen btw, becuase of modulo, but anyway
nextindex = nextindex - intCharSetLen
}
strOutVal += strCharSet.charAt(nextindex);
}
else { //char not found in set, so add it as is
strOutVal += nextchar;
}
}
return strOutVal;
}
//function used with jupload version 2.4+
function jupload_result(result_html) {
window.setTimeout(function() {
document.open();
document.write(result_html);
document.close();
}, 1000);
}
//Returns an array of StyleSheet DOM objects for the tags on a page
//See http://www.javascriptkit.com/domref/stylesheet.shtml for the available properties you can use on the array
function getAllSheets() {
//if you want ICEbrowser's limited support, do it this way
if (!window.ScriptEngine && navigator.__ice_version) {
//IE errors if it sees navigator.__ice_version when a window is closing
//window.ScriptEngine hides it from that
return document.styleSheets;
}
if (document.getElementsByTagName) {
//DOM browsers - get link and style tags
var Lt = document.getElementsByTagName('link');
var St = document.getElementsByTagName('style');
} else if (document.styleSheets && document.all) {
//not all browsers that supply document.all supply document.all.tags
//but those that do and can switch stylesheets will also provide
//document.styleSheets (checking for document.all.tags produces errors
//in IE [WHY?!], even though it does actually support it)
var Lt = document.all.tags('LINK'), St = document.all.tags('STYLE');
} else { return []; } //lesser browser - return a blank array
//for all link tags ...
for (var x = 0, os = []; Lt[x]; x++) {
//check for the rel attribute to see if it contains 'style'
if (Lt[x].rel) {
var rel = Lt[x].rel;
} else if (Lt[x].getAttribute) {
var rel = Lt[x].getAttribute('rel');
} else { var rel = ''; }
if (typeof (rel) == 'string' && rel.toLowerCase().indexOf('style') + 1) {
//fill os with linked stylesheets
os[os.length] = Lt[x];
}
}
return os;
}
//Generating Pop-up Print Preview page
//Creates a new window, loads the style sheets from the parrent window (for proper site rendering),
//then grabs the HTML from the tag and substrings looking for the special YM print comments
function createPrintPagePopup() {
//Creating new page
var pp = window.open('', 'print', 'height=600,width=600,scrollbars=yes');
//Adding HTML opening tag with � portion
pp.document.writeln('');
pp.document.writeln('');
pp.document.writeln('Print Preview')
//include all the stylesheets that are on the current page
for (var x = 0, ss = getAllSheets(); ss[x]; x++) {
//for each stylesheet ...
pp.document.writeln('');
}
pp.document.writeln('');
pp.document.writeln('');
pp.document.writeln('');
pp.document.writeln('')
//Adding Body Tag
pp.document.writeln('');
//Adding form Tag
pp.document.writeln(', and
pp.document.writeln('